var t = require;
var e = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("BootConst"),
    a = t("EventData"),
    i = t("GameData"),
    s = t("Util"),
    c = t("View"),
    l = t("Platforms"),
    u = t("Sounds"),
    p = t("WatchVideo"),
    f = t("ConfS"),
    d = t("fightManager"),
    h = t("fightView"),
    y = t("fun"),
    g = t("guide"),
    v = t("mainView"),
    m = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (
                (e.res = "victory"),
                (e.isMask = !0),
                (e.zIndex = 1),
                (e.money1 = new a.default(0)),
                (e.money2 = new a.default(0)),
                (e.money3 = new a.default(0)),
                (e.money4 = new a.default(0)),
                e
            );
        }
        return (
            n(e, t),
            (e.prototype.view_money1 = function (t, e) {
                t.set(1, e);
            }),
            (e.prototype.view_money2 = function (t, e) {
                t.set(0, e);
            }),
            (e.prototype.view_money3 = function (t, e) {
                t.set(1, e);
            }),
            (e.prototype.view_money4 = function (t, e) {
                t.set(0, e);
            }),
            (e.prototype.onEnable = function () {
                Adv_skd.default.instance.showInterstitialAd();
                if (d.default.ispvp) {
                    var t = 1 == d.default.adata.type;
                    (this.find("ms/money1").active = t),
                        (this.find("ms/money2").active = !t),
                        (this.money1.value = d.default.adata.count),
                        (this.money2.value = d.default.adata.count);
                } else
                    d.default.fubendata.CoinReward
                        ? ((this.money1.value = d.default.fubendata.CoinReward), (this.find("ms/money1").active = !0))
                        : (this.find("ms/money1").active = !1),
                        d.default.fubendata.DiamondReward
                            ? ((this.money2.value = d.default.fubendata.DiamondReward),
                              (this.find("ms/money2").active = !0))
                            : (this.find("ms/money2").active = !1);
                var e = this.showView(h.default).jb.value,
                    o = this.showView(h.default).zs.value;
                if (
                    ((this.find("ms2/money3").active = e > 0),
                    (this.money3.value = e),
                    (this.find("ms2/money4").active = o > 0),
                    (this.money4.value = o),
                    u.Sounds.playFX("胜利音效"),
                    cc.Canvas.instance.node.emit("战斗结束", !0),
                    d.default.ispvp)
                ) {
                    if (null == (n = f.DatasManager.HeroDatasById[i.default.hero])) return;
                    l.default.platformCtrl.dd(r.dd.PVPVictory, {
                        eventTime: Date.now(),
                        currentHeroID: i.default.hero,
                        currentLV: y.getHeroLv(i.default.hero),
                        EnemyLv: d.default.adata.herolvs[d.default.adata.data.ID],
                        StageUseTime: Date.now() - d.default.进入时间,
                        currentEquip1: i.default.equips.includes(n.equipids[0]),
                        currentEquip2: i.default.equips.includes(n.equipids[1]),
                        currentEquip3: i.default.equips.includes(n.equipids[2]),
                        currentSkill1LV: y.getSkillLv(n.skills[0]),
                        currentSkill2LV: y.getSkillLv(n.skills[1]),
                        currentSkill3LV: y.getSkillLv(n.skills[2])
                    });
                } else {
                    var n;
                    if (
                        (d.default.fubendata.ID > l.default.userStorage.fubenId &&
                            ((l.default.userStorage.fubenId = d.default.fubendata.ID),
                            l.default.userStorage.setDirty(),
                            l.default.platformCtrl.dd(r.dd.FirstVictory, {StageID: d.default.fubendata.ID})),
                        null == (n = f.DatasManager.HeroDatasById[i.default.hero]))
                    )
                        return;
                    l.default.platformCtrl.dd(r.dd.StageVictory, {
                        eventTime: Date.now(),
                        StageID: d.default.fubendata.ID,
                        currentHeroID: i.default.hero,
                        currentLV: y.getHeroLv(i.default.hero),
                        StageUseTime: Date.now() - d.default.进入时间,
                        currentEquip1: i.default.equips.includes(n.equipids[0]),
                        currentEquip2: i.default.equips.includes(n.equipids[1]),
                        currentEquip3: i.default.equips.includes(n.equipids[2]),
                        currentSkill1LV: y.getSkillLv(n.skills[0]),
                        currentSkill2LV: y.getSkillLv(n.skills[1]),
                        currentSkill3LV: y.getSkillLv(n.skills[2])
                    });
                }
            }),
            (e.prototype.onClick = function (t) {
                var e = this;
                switch (("领取" === t && l.default.userStorage.score <= 0 && (t = "双倍领取"), t)) {
                    case "领取":
                        this.reward();
                        break;
                    case "双倍领取":
                        p.default.show(r.dd.victory, function () {
                            e.reward(2);
                        });
                }
            }),
            (e.prototype.reward = function (t) {
                if ((void 0 === t && (t = 1), d.default.ispvp))
                    s.reward(d.default.adata.type, d.default.adata.count * t, "PVP胜利" + t + "倍领取");
                else {
                    var e = d.default.fubendata;
                    e.CoinReward && s.reward(1, e.CoinReward * t, "副本胜利" + t + "倍领取"),
                        e.DiamondReward && s.reward(0, e.DiamondReward * t, "副本胜利" + t + "倍领取");
                }
                this.money3.value > 0 && s.reward(1, this.money3.value, "fall"),
                    this.money4.value > 0 && s.reward(0, this.money4.value, "fall"),
                    this.rewardNext();
            }),
            (e.prototype.rewardNext = function () {
                var t = this;
                (this.view.opacity = 0),
                    l.default.显示胜利宝箱(f.DatasManager.胜利宝箱标题, !g.default.isRuning, function () {
                        t.wrongTouchNext();
                    });
            }),
            (e.prototype.wrongTouchNext = function () {
                this.hideView(), this.hideView(h.default), this.showView(v.default);
            }),
            e
        );
    })(c.default);
o.default = m;
